package com.ruoyi;

import com.ruoyi.framework.aspectj.DatabaseConnectionAspect;
import org.apache.commons.codec.digest.DigestUtils;

public class TokenGenerator {
    public static void main(String[] args) {
        // 数据库连接信息

        //String dbUrl = "jdbc:mysql://49.234.186.218:3306/hazard_tracking?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
        String dbUrl = "jdbc:mysql://127.0.0.1:13306/hazard_tracking?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
        String dbUsername = "root";

        // 生成token的数据源
        StringBuilder tokenData = new StringBuilder();
        tokenData.append(dbUrl);
        tokenData.append(dbUsername);
        tokenData.append("hazard_tracking_app"); // 与代码中保持一致

        // 生成token
        String token = DigestUtils.sha256Hex(tokenData.toString());

        System.out.println("Generated Database Token: " + token);
        System.out.println("Token Length: " + token.length());
    }
}
